/**
 * 日志相关 API
 */

import request from '@/utils/request'


/**
 * 获取操作日志列表
 * @param params 查询参数
 */
export function getOperationLogListApi(
  params: OperationLogQueryParams
): Promise<ApiResponse<OperationLogListResponse>> {
  return request.get('/logs/operations', { params })
}

/**
 * 获取登录日志列表
 * @param params 查询参数
 */
export function getLoginLogListApi(
  params: LoginLogQueryParams
): Promise<ApiResponse<LoginLogListResponse>> {
  return request.get('/logs/logins', { params })
}

/**
 * 清空操作日志
 */
export function clearOperationLogsApi(): Promise<ApiResponse<void>> {
  return request.delete('/logs/operations')
}

/**
 * 清空登录日志
 */
export function clearLoginLogsApi(): Promise<ApiResponse<void>> {
  return request.delete('/logs/logins')
}

/**
 * 导出操作日志
 * @param params 查询参数
 */
export function exportOperationLogsApi(
  params: OperationLogQueryParams
): Promise<ApiResponse<Blob>> {
  return request.get('/logs/operations/export', {
    params,
    responseType: 'blob'
  })
}

/**
 * 导出登录日志
 * @param params 查询参数
 */
export function exportLoginLogsApi(params: LoginLogQueryParams): Promise<ApiResponse<Blob>> {
  return request.get('/logs/logins/export', {
    params,
    responseType: 'blob'
  })
}

